//
//  YQChangeHomeVC.m
//  industry
//
//  Created by 王雅强 on 2021/1/21.
//  Copyright © 2021 Haier. All rights reserved.
//

#import "YQChangeHomeVC.h"
#import "XLBaseTabBarController.h"

@interface YQChangeHomeVC ()

@property (nonatomic, strong) UIView *containView;
@property (nonatomic, strong) XLBaseTabBarController *currentTab;

@end

@implementation YQChangeHomeVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // 1.添加所有的子控制器
    [self setupAllViewController];
    self.containView = [[UIView alloc]init];
    self.containView.frame = self.view.bounds;
    [self.view addSubview:self.containView];
    
    
    [self changeViewContorller:true];
}

- (void)setupAllViewController
{
    // 内部员工
    XLBaseTabBarController *tabBarVC = [XLBaseTabBarController tabBarWithStaff:true];
    [self addChildViewController:tabBarVC];
    
    // 非内部员工
    XLBaseTabBarController *vc = [XLBaseTabBarController tabBarWithStaff:false];
    [self addChildViewController:vc];
    
    
}


- (void)changeViewContorller:(BOOL)isStaff{
    
    UIViewController *vc;
    if (isStaff) {
       vc = self.childViewControllers[0];
    }else{
        vc = self.childViewControllers[1];
    }
    [self.containView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.currentTab = (XLBaseTabBarController *)vc;
    vc.view.frame = self.containView.bounds;
    [self.containView addSubview:vc.view];
}

- (void)InterfaceInit{
    [self.currentTab setSelectedIndex:0];
}

@end
